package com.youngball.web.webconfig;

/**
 * Created by asus on 2016/6/13.
 */

import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.models.dto.ApiInfo;
import com.mangofactory.swagger.plugin.EnableSwagger;
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@Configuration
@EnableSwagger
@ComponentScan(basePackages = {"com.youngball.web.controller"})
@EnableWebMvc
public class SwaggerConfig {

    @Autowired
    private SpringSwaggerConfig springSwaggerConfig;
    @Bean  // Don't forget the @Bean annotation
    public SwaggerSpringMvcPlugin customImplementation() {
        return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
                .apiInfo(apiInfo())
                .includePatterns("/(?!error).*")
                ;
    }

    private ApiInfo apiInfo() {
//  ApiInfo(String title, String description, String termsOfServiceUrl, String contact, String license, String licenseUrl)
        ApiInfo apiInfo = new ApiInfo("Rest API.", "使用Swagger产生的API接口文档",
                null, null,
                "API许可证", null
        );
        return apiInfo;
    }
}
